Question: For each positive integer $n$, let $f(n) = n^4 - 360n^2 + 400$. What is the sum of all values of $f(n)$ that are prime numbers?
Explanation: Consider the function $g(x) = x^2 - 360x + 400$, then obviously $f(x) = g(x^2)$.

The roots of $g$ are: \begin{align*}
x_{1,2}
= \frac{ 360 \pm \sqrt{ 360^2 - 4\cdot 400 } }2
= 180 \pm 80 \sqrt 5
\end{align*}We can then write $g(x) = (x - 180 - 80\sqrt 5)(x - 180 + 80\sqrt 5)$, and thus $f(x) = (x^2 - 180 - 80\sqrt 5)(x^2 - 180 + 80\sqrt 5)$.

We would now like to factor the right hand side further, using the formula $(x^2 - y^2) = (x-y)(x+y)$. To do this, we need to express both constants as squares of some other constants. Luckily, we have a pretty good idea what they look like.

We are looking for rational $a$ and $b$ such that $(a+b\sqrt 5)^2 = 180 + 80\sqrt 5$. Expanding the left hand side and comparing coefficients, we get $ab=40$ and $a^2 + 5b^2 = 180$. We can easily guess (or compute) the solution $a=10$, $b=4$.

Hence $180 + 80\sqrt 5 = (10 + 4\sqrt 5)^2$, and we can also easily verify that $180 - 80\sqrt 5 = (10 - 4\sqrt 5)^2$.

We now know the complete factorization of $f(x)$: \begin{align*}
f(x) = (x - 10 - 4\sqrt 5)(x + 10 + 4\sqrt 5)(x - 10 + 4\sqrt 5)(x + 10 - 4\sqrt 5)
\end{align*}As the final step, we can now combine the factors in a different way, in order to get rid of the square roots.

We have $(x - 10 - 4\sqrt 5)(x - 10 + 4\sqrt 5) = (x-10)^2 - (4\sqrt 5)^2 = x^2 - 20x + 20$, and $(x + 10 - 4\sqrt 5)(x + 10 + 4\sqrt 5) = x^2 + 20x + 20$.

Hence we obtain the factorization $f(x) = (x^2 - 20x + 20)(x^2 + 20x + 20)$.

For $x\geq 20$, both terms are positive and larger than one, hence $f(x)$ is not prime. For $1<x<19$, the second factor is positive and the first one is negative, hence $f(x)$ is not prime. The remaining cases are $x=1$ and $x=19$. In both cases, $f(x)$ is indeed a prime, and their sum is $f(1) + f(19) = 41 + 761 = \boxed{802}$.